package com.zhiyun.service.impl;

import com.zhiyun.domain.Teacher;
import com.zhiyun.mapper.TeacherMapper;
import com.zhiyun.service.TeacherService;
import com.zhiyun.util.Db;
import com.zhiyun.vo.Result;

import java.util.List;

/**
 * @author zc
 * @Date 2025/4/29 下午8:50
 */
public class TeacherServiceImpl implements TeacherService {
    TeacherMapper teacherMapper = Db.getMapper(TeacherMapper.class);
    @Override
    public Result myInfo(int teacherId) {
        Teacher teacher = teacherMapper.selectByPrimaryKey(teacherId);
        return Result.ok(teacher);
    }

    @Override
    public Result updateTeacher(Teacher teacher) {
        int rows = teacherMapper.updateByPrimaryKey(teacher);
        if (rows > 0) {
            return Result.okMsg("修改成功");
        }
        return Result.fail("修改失败");
    }

    @Override
    public Result AllTeacher() {
       List<Teacher> teachers =  teacherMapper.findAll();
        return Result.ok(teachers);
    }
}
